/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package model.impl;

import java.util.Collection;

import model.AssociationActorSerie;
import model.ModelPackage;
import model.Role;
import model.SeasonPackage;
import model.Serie;

import model.SerieRole;
import model.SeriesPackSerie;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Serie</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link model.impl.SerieImpl#getAllSeason <em>All Season</em>}</li>
 *   <li>{@link model.impl.SerieImpl#getSerieActor <em>Serie Actor</em>}</li>
 *   <li>{@link model.impl.SerieImpl#getRolesComponet <em>Roles Componet</em>}</li>
 *   <li>{@link model.impl.SerieImpl#getSeriesPackSerie <em>Series Pack Serie</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SerieImpl extends EntityDescriptionImpl implements Serie {
	/**
	 * The cached value of the '{@link #getAllSeason() <em>All Season</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAllSeason()
	 * @generated
	 * @ordered
	 */
	protected SeasonPackage allSeason;

	/**
	 * The cached value of the '{@link #getSerieActor() <em>Serie Actor</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSerieActor()
	 * @generated
	 * @ordered
	 */
	protected EList<AssociationActorSerie> serieActor;

	/**
	 * The cached value of the '{@link #getRolesComponet() <em>Roles Componet</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRolesComponet()
	 * @generated
	 * @ordered
	 */
	protected EList<SerieRole> rolesComponet;

	/**
	 * The cached value of the '{@link #getSeriesPackSerie() <em>Series Pack Serie</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSeriesPackSerie()
	 * @generated
	 * @ordered
	 */
	protected SeriesPackSerie seriesPackSerie;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected SerieImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ModelPackage.Literals.SERIE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SeasonPackage getAllSeason() {
		return allSeason;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetAllSeason(SeasonPackage newAllSeason, NotificationChain msgs) {
		SeasonPackage oldAllSeason = allSeason;
		allSeason = newAllSeason;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackage.SERIE__ALL_SEASON, oldAllSeason, newAllSeason);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setAllSeason(SeasonPackage newAllSeason) {
		if (newAllSeason != allSeason) {
			NotificationChain msgs = null;
			if (allSeason != null)
				msgs = ((InternalEObject)allSeason).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModelPackage.SERIE__ALL_SEASON, null, msgs);
			if (newAllSeason != null)
				msgs = ((InternalEObject)newAllSeason).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModelPackage.SERIE__ALL_SEASON, null, msgs);
			msgs = basicSetAllSeason(newAllSeason, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.SERIE__ALL_SEASON, newAllSeason, newAllSeason));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<AssociationActorSerie> getSerieActor() {
		if (serieActor == null) {
			serieActor = new EObjectResolvingEList<AssociationActorSerie>(AssociationActorSerie.class, this, ModelPackage.SERIE__SERIE_ACTOR);
		}
		return serieActor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<SerieRole> getRolesComponet() {
		if (rolesComponet == null) {
			rolesComponet = new EObjectContainmentEList<SerieRole>(SerieRole.class, this, ModelPackage.SERIE__ROLES_COMPONET);
		}
		return rolesComponet;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SeriesPackSerie getSeriesPackSerie() {
		if (seriesPackSerie != null && seriesPackSerie.eIsProxy()) {
			InternalEObject oldSeriesPackSerie = (InternalEObject)seriesPackSerie;
			seriesPackSerie = (SeriesPackSerie)eResolveProxy(oldSeriesPackSerie);
			if (seriesPackSerie != oldSeriesPackSerie) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ModelPackage.SERIE__SERIES_PACK_SERIE, oldSeriesPackSerie, seriesPackSerie));
			}
		}
		return seriesPackSerie;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SeriesPackSerie basicGetSeriesPackSerie() {
		return seriesPackSerie;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetSeriesPackSerie(SeriesPackSerie newSeriesPackSerie, NotificationChain msgs) {
		SeriesPackSerie oldSeriesPackSerie = seriesPackSerie;
		seriesPackSerie = newSeriesPackSerie;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackage.SERIE__SERIES_PACK_SERIE, oldSeriesPackSerie, newSeriesPackSerie);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSeriesPackSerie(SeriesPackSerie newSeriesPackSerie) {
		if (newSeriesPackSerie != seriesPackSerie) {
			NotificationChain msgs = null;
			if (seriesPackSerie != null)
				msgs = ((InternalEObject)seriesPackSerie).eInverseRemove(this, ModelPackage.SERIES_PACK_SERIE__SERIE, SeriesPackSerie.class, msgs);
			if (newSeriesPackSerie != null)
				msgs = ((InternalEObject)newSeriesPackSerie).eInverseAdd(this, ModelPackage.SERIES_PACK_SERIE__SERIE, SeriesPackSerie.class, msgs);
			msgs = basicSetSeriesPackSerie(newSeriesPackSerie, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.SERIE__SERIES_PACK_SERIE, newSeriesPackSerie, newSeriesPackSerie));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ModelPackage.SERIE__SERIES_PACK_SERIE:
				if (seriesPackSerie != null)
					msgs = ((InternalEObject)seriesPackSerie).eInverseRemove(this, ModelPackage.SERIES_PACK_SERIE__SERIE, SeriesPackSerie.class, msgs);
				return basicSetSeriesPackSerie((SeriesPackSerie)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ModelPackage.SERIE__ALL_SEASON:
				return basicSetAllSeason(null, msgs);
			case ModelPackage.SERIE__ROLES_COMPONET:
				return ((InternalEList<?>)getRolesComponet()).basicRemove(otherEnd, msgs);
			case ModelPackage.SERIE__SERIES_PACK_SERIE:
				return basicSetSeriesPackSerie(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ModelPackage.SERIE__ALL_SEASON:
				return getAllSeason();
			case ModelPackage.SERIE__SERIE_ACTOR:
				return getSerieActor();
			case ModelPackage.SERIE__ROLES_COMPONET:
				return getRolesComponet();
			case ModelPackage.SERIE__SERIES_PACK_SERIE:
				if (resolve) return getSeriesPackSerie();
				return basicGetSeriesPackSerie();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ModelPackage.SERIE__ALL_SEASON:
				setAllSeason((SeasonPackage)newValue);
				return;
			case ModelPackage.SERIE__SERIE_ACTOR:
				getSerieActor().clear();
				getSerieActor().addAll((Collection<? extends AssociationActorSerie>)newValue);
				return;
			case ModelPackage.SERIE__ROLES_COMPONET:
				getRolesComponet().clear();
				getRolesComponet().addAll((Collection<? extends SerieRole>)newValue);
				return;
			case ModelPackage.SERIE__SERIES_PACK_SERIE:
				setSeriesPackSerie((SeriesPackSerie)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ModelPackage.SERIE__ALL_SEASON:
				setAllSeason((SeasonPackage)null);
				return;
			case ModelPackage.SERIE__SERIE_ACTOR:
				getSerieActor().clear();
				return;
			case ModelPackage.SERIE__ROLES_COMPONET:
				getRolesComponet().clear();
				return;
			case ModelPackage.SERIE__SERIES_PACK_SERIE:
				setSeriesPackSerie((SeriesPackSerie)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ModelPackage.SERIE__ALL_SEASON:
				return allSeason != null;
			case ModelPackage.SERIE__SERIE_ACTOR:
				return serieActor != null && !serieActor.isEmpty();
			case ModelPackage.SERIE__ROLES_COMPONET:
				return rolesComponet != null && !rolesComponet.isEmpty();
			case ModelPackage.SERIE__SERIES_PACK_SERIE:
				return seriesPackSerie != null;
		}
		return super.eIsSet(featureID);
	}

} //SerieImpl
